package com.icss.lesson4;

public class TestMain3 {
    public static int count = 0;
    public static void main(String[] args) {

        new Thread("线程1") {
            @Override
            public void run() {
//                synchronized(this)
                synchronized(TestMain3.class) {
                    for (int i = 0; i < 100 ; i++) {
                        System.out.println(Thread.currentThread() + "@" + count++);
                    }
                }
            }
        }.start();

        new Thread("线程2") {
            @Override
            public void run() {
                synchronized(TestMain3.class) {
                    for (int i = 0; i < 100 ; i++) {
                        System.out.println(Thread.currentThread() + "@" + count++);
                    }
                }

            }
        }.start();

    }
}
